package com.harboursoftware.xstorage.ac;

/**
 * 权限。
 * <a href="http://docs.amazonwebservices.com/AmazonS3/2006-03-01/dev/S3_ACLs.html">
 * Amazon S3 Access Control Lists</a>
 * @author Simon Leung
 * @since 0.1
 */
public enum Permission {
    READ,
    WRITE,
    READ_ACP,
    WRITE_ACP,
    FULL_CONTROL;
    
    /**
     * convert string to Permission
     * @param the string
     * @return the permission
     * @throws IllegalArgumentException when the string is invalid
     */
    public static Permission fromString(String string) {
        if("READ".equals(string)) {
            return READ;
        } else if("WRITE".equals(string)) {
            return WRITE;
        } else if("READ_ACP".equals(string)) {
            return READ_ACP;
        } else if("WRITE_ACP".equals(string)) {
            return WRITE_ACP;
        } else if("FULL_CONTROL".equals(string)) {
            return FULL_CONTROL;
        } else {
            throw new IllegalArgumentException("The argument string is invalid, Valid Values: FULL_CONTROL | WRITE | WRITE_ACP | READ | READ_ACP.");
        }
    }
}
